package com.training.file;

import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileOutputStream;

public class BUfferOPStramEx {

	public static void main(String[] args) throws Exception {

	 
		
		DataInputStream dataInputStream = new DataInputStream(System.in);

		String toFileName = "C:\\Anjali\\dataIn.txt";
		
		File toFile  = new File(toFileName);
		
		if(!toFile.exists())
		{
			toFile.createNewFile();
		}
 
		FileOutputStream fileOutputStream = new FileOutputStream(toFile);
 
		BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream,1024);
	 	
		char ch ;
		
		while ((ch = (char) dataInputStream.read()) != '!' ) {
			
			bufferedOutputStream.write(ch);
			
		}
		
		bufferedOutputStream.close();
		
		fileOutputStream.close();
	}
}
